/*
	DIMGA
	Distributed Island Model Genetic Algorithm 

	Copyright (c) 2006 Nikola Sivacki nsivacki@gmail.com

	This program is free software; you can redistribute it and/or
	modify in under the terms of the GNU General Public Licence as
	published by the Free Software Foundation; either version 2 of
	the Licence, or [at your option] any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAT PURPOSE. See the
	GNU General Public Licence for more details.

	You should have received a copy of the GNU General Public Licence
	along with this program; if not, write to the Free Software 
	Foundation Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
// Genotype.cpp
#include <stdlib.h>
#include <fstream>
#include "genotype.h"

Genotype::Genotype(long _lSize)
{
	m_data = new unsigned char[_lSize];
	m_lSize= _lSize;
	for(long i = 0 ; i < m_lSize; i++)
	{
//	    m_data[i] = rand()%250 - 125;
            m_data[i] = 1;
	}
}

Genotype::~Genotype()
{
	delete[] m_data;
}

void Genotype::setGenome(unsigned char* source)
{
    for ( int i = 0 ; i < m_lSize; i++)
    {
        m_data[i] = source[i];
    }

}

void Genotype::toFile(const char* file)
{
    std::ofstream fs(file);
//    fprintf(stderr, "lsize: %d ", m_lSize);

    for(int i = 0 ; i < m_lSize; i++)
    {
//        fprintf(stderr, "%d ", i);
        fs << m_data[i];
    }
    
    fs.close();
}

